<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 1.输入年份判断改年是平年还是闰年 能够被4整除 且不能被100整除 或者 能够被400整除的年份就是闰年 其他的就是平年 -->
    <!-- 请输入年份<input class="year" type="text" /><button class="btn">查看是不是闰年</button>
    <script>
        var but = document.getElementsByClassName("btn")[0];
        var inp = document.getElementsByClassName("year")[0];
        but.onclick = function(){
            var year = inp.value;
            if((year%4==0 && year%100 !=0) || year%400 == 0){
                alert("润年")
            }else{
                alert("平年");
            }
        } 
        </script>
    -->

    <!-- 2.计算两个文本框的加减乘除 文本框 + 文本框 按钮（=） 文本框（结果） 提示：可以通过 input.value = "值" 来设置 input里的值。 -->
    <!-- <input type="text" id="txt1">
        <input type="text" id="fh">
        <input type="text" id="txt2">
        <input type="button" id="btn" value="计算">
        <input type="text" readonly id="res">
        <script>
            var txt1 = document.getElementById("txt1");
            var fh = document.getElementById("fh");
            var txt2 = document.getElementById("txt2");
            var btn = document.getElementById("btn");
            var res = document.getElementById("res");
            btn.onclick = function () {
                //转成数据类型
                var a = txt1.value * 1;
                var b = fh.value + "";
                var c = txt2.value * 1;
                //判断数据类型并进行相对的运算
                switch (b) {
                    case "+": res.value = a + c;
                        break;
                    case "-": res.value = a - c;
                        break;
                    case "*": res.value = a * c;
                        break;
                    case "/": res.value = a / c;
                        break;
                }
            }

    </script> -->
    <!-- 3.根据输入的三个数字，判断是这一年的第几天 -->
    <!-- <script>
        var year = parseInt(prompt("输入年份"));
        var month = parseInt(prompt("输入月份"));
        var day = parseInt(prompt("输入日"));
        var temp = 0;
        var sum = 0;
        if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
            temp = 29;
        } else {
            temp = 28;
        }
        switch (month) {
            case 1:
                sum = day;
                break;
            case 2:
                sum = day + 31
                break;
            case 3:
                sum = day + 31 + temp;
                break;
            case 4: sum = day + 31 + temp + 31;
                break;
            case 5: sum = day + 31 + temp + 31 + 30;
                break;
            case 6: sum = day + 31 + temp + 31 + 30 + 31;
                break;
            case 7: sum = day + 31 + temp + 31 + 30 + 31 + 30;
                break;
            case 8: sum = day + 31 + temp + 31 + 30 + 31 + 30 + 31;
                break;
            case 9: sum = day + 31 + temp + 31 + 30 + 31 + 30 + 31 + 30;
                break;
            case 10: sum = day + 31 + temp + 31 + 30 + 31 + 30 + 31 + 30 + 31;
                break;
            case 11: sum = day + 31 + temp + 31 + 30 + 31 + 30 + 31 + 30 + 31 + 30;
                break;
            case 12: sum = day + 31 + temp + 31 + 30 + 31 + 30 + 31 + 30 + 31 + 30 + 31;
                break;
        }
        alert("第" + sum + "天");
    </script> -->
    <!-- 输入月份，显示当月的天数。 -->
    <script>

        var year = parseInt(prompt("请输入年份"))
        var month = parseInt(prompt("请输入月份"))

        if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
            console.log(31 + "天")
        }
        else if (month == 4 || month == 6 || month == 9 || month == 11) {
            console.log(30 + "天")
        }
        else if (year % 4 == 0 && year % 100 !== 0 && month == 2) {
            console.log(29 + "天")
        }
        else { (console.log(28 + "天")) }
    </script>
</body>

</html>